package com.handong.handserialprogram.utils;

import android.content.Context;
import android.content.Intent;

/**
 * Created by userKey on 2017/8/23.
 */

public class LockUtil {

    private static final int KEY_FLAGS = 32;
    private static final int DISABLE_STATUS_BAR = 65536;
    private static final int ENABLE_STATUS_BAR = 0;

    private static final String HOME_KEY = "lockHome";
    private static final String MENU_KEY = "lockMenu";
    private static final String STATUS_BAR_KEY = "lockStatus";

    private static final String SET_TIME = "android.rfid.SET_TIME";
    private static final String LOCK_HOME_ACTION = "android.rfid.LOCK_HOME";
    private static final String LOCK_MENU_ACTION = "android.rfid.LOCK_MENU";
    private static final String LOCK_STATUS_BAR_ACTION = "android.rfid.DISABLE_STATUSBAR";
    private static final String SET_APN = "android.rfid.SET_APN";
    private static String APN_SETTINGS = "android.rfid.APN_SETTING";

    private static final String REPAIR_TIME_PASSWORD = "android.rfid.REPAIR_TIME_PASSWORD";

    public static boolean lockHomeClick(Context context) {
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_HOME_ACTION);
        intent.putExtra(HOME_KEY, true);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }

    public static boolean releaseLockHome(Context context) {
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_HOME_ACTION);
        intent.putExtra(HOME_KEY, false);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }

    public static boolean lockMenuClick(Context context) {
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_MENU_ACTION);
        intent.putExtra(MENU_KEY, true);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }

    public static boolean releaseMenuLock(Context context) {
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_MENU_ACTION);
        intent.putExtra(MENU_KEY, false);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }

    public static boolean lockStatusBar(Context context) {
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_STATUS_BAR_ACTION);
        intent.putExtra(STATUS_BAR_KEY, DISABLE_STATUS_BAR);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }

    public static boolean releaseStatusBarLock(Context context){
        Intent intent = new Intent();
        intent.addFlags(KEY_FLAGS);
        intent.setAction(LOCK_STATUS_BAR_ACTION);
        intent.putExtra(STATUS_BAR_KEY, ENABLE_STATUS_BAR);
        context.getApplicationContext().sendBroadcast(intent);
        return true;
    }
}
